/**
 * DNS 模块
 * DNS 模块用于解析域名
 */

var dns = require('dns');

dns.lookup('www.github.com', function onLookup(err, address, family) {
   console.log('ip 地址:', address);
   dns.reverse(address, function (err, hostnames) {
   if (err) {
      console.log(err.stack);
   }

   console.log('反向解析 ' + address + ': ' + JSON.stringify(hostnames));
});  
});

// ip 地址: 192.30.253.113
// Error: getHostByAddr ENOTFOUND 192.30.253.113
//     at errnoException (dns.js:27:10)
//     at QueryReqWrap.onresolve [as oncomplete] (dns.js:214:19)
// 反向解析 192.30.253.113: undefined